package com.cw.jeeyt.service.converter.process;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.process.ActReModelBo;
import com.cw.jeeyt.dao.model.process.ActReModelDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 转换类
 *
 * @author chenw
 * @date 2019-03-23 23:37:05
 */
public class ActReModelConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static ActReModelBo do2Bo(ActReModelDo model) {
        if (model == null) {
            return null;
        }
        ActReModelBo bo = new ActReModelBo();
        bo.setId_(model.getId_());
        bo.setRev_(model.getRev_());
        bo.setName_(model.getName_());
        bo.setKey_(model.getKey_());
        bo.setCategory_(model.getCategory_());
        bo.setCreateTime_(model.getCreateTime_());
        bo.setLastUpdateTime_(model.getLastUpdateTime_());
        bo.setVersion_(model.getVersion_());
        bo.setMetaInfo_(model.getMetaInfo_());
        bo.setDeploymentId_(model.getDeploymentId_());
        bo.setEditorSourceValueId_(model.getEditorSourceValueId_());
        bo.setEditorSourceExtraValueId_(model.getEditorSourceExtraValueId_());
        bo.setTenantId_(model.getTenantId_());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static ActReModelDo bo2Do(ActReModelBo bo) {
        if (bo == null) {
            return null;
        }
        ActReModelDo model = new ActReModelDo();
        model.setId_(bo.getId_());
        model.setRev_(bo.getRev_());
        model.setName_(bo.getName_());
        model.setKey_(bo.getKey_());
        model.setCategory_(bo.getCategory_());
        model.setCreateTime_(bo.getCreateTime_());
        model.setLastUpdateTime_(bo.getLastUpdateTime_());
        model.setVersion_(bo.getVersion_());
        model.setMetaInfo_(bo.getMetaInfo_());
        model.setDeploymentId_(bo.getDeploymentId_());
        model.setEditorSourceValueId_(bo.getEditorSourceValueId_());
        model.setEditorSourceExtraValueId_(bo.getEditorSourceExtraValueId_());
        model.setTenantId_(bo.getTenantId_());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<ActReModelBo> doList2BoList(List<ActReModelDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), ActReModelConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<ActReModelDo> boList2DoList(List<ActReModelBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), ActReModelConverter::bo2Do));
    }
}